<?php

if($_POST['xmlhttp']){
	include_once('config.php');
	include_once(mnminclude.'group.php');

	$group = new Group();
	$group->id = $_POST['group'];
	$group->read();
	
	$show = $_POST['show'];
	if ($show > 0) {
			$num = $db->get_var("SELECT COUNT(*) FROM " . table_group_user . " WHERE gu_group_id=" . $_POST['group'] . " AND gu_index_show > 0 AND gu_user_id=" .$_POST['user']);
			if ($num > 0) {
				echo "already";
				die();
			}
			//check if already eight user show
			$num = $db->get_var("SELECT COUNT(*) FROM " . table_group_user . " WHERE gu_group_id=" . $_POST['group'] . " AND gu_index_show > 0");
			if ($num > 7) {
				echo "full";
				die();
			}
	}
	
	$sendmsg = $group->set_user_indexshow($_POST['user'],$_POST['show']);
	//echo $sendmsg;die();
	switch ($sendmsg) {
		case true:
			echo "success";	
			die();
			break;
		default:
			echo "fail";
			die();
			break;
	}
}
?>